#include "libconfig.h"
#include "InSdkDevInfo.h"

#define DEF_TAG             "SetDevInfo"

Com_void Ext_InSdkSetInfo_UUID(char *uuid)
{
    ComNullRetVoid(uuid);

    struct config *conf = conf_load(DEF_INI_IOT_CONFIG);
    conf_set_string(conf, "cfg:uuid", uuid);
    conf_save(conf);

    if(strcmp(uuid,conf_get_string(conf, "cfg:uuid")) != 0)
    {
        PRT_ERR(DEF_TAG,"failed of set uid\n");
    }
    else
    {
        PRT_DBG(DEF_TAG,"now uuid: %s\n",uuid);
    }
    conf_unload(conf);
}

Com_void Ext_InSdkSetInfo_Authkey(char *key)
{
    ComNullRetVoid(key);

    struct config *conf = conf_load(DEF_INI_IOT_CONFIG);
    conf_set_string(conf, "cfg:authkey", key);
    conf_save(conf);

    if(strcmp(key,conf_get_string(conf, "cfg:authkey")) != 0)
    {
        PRT_ERR(DEF_TAG,"failed of set key\n");
    }
    else
    {
        PRT_DBG(DEF_TAG,"now authkey: %s\n",key);
    }
    conf_unload(conf);
}

Com_void Ext_InSdkSetInfo_Pid(char *pid)
{
    ComNullRetVoid(pid);

    struct config *conf = conf_load(DEF_INI_IOT_CONFIG);
    conf_set_string(conf, "cfg:pid", pid);
    conf_save(conf);

    if(strcmp(pid,conf_get_string(conf, "cfg:pid")) != 0)
    {
        PRT_ERR(DEF_TAG,"failed of set pid\n");
    }
    else
    {
        PRT_DBG(DEF_TAG,"now pid: %s\n",pid);
    }
    conf_unload(conf);
}